<template>
  <div>
    <el-page-header :icon="null" title="企业门户管理系统">
      <template #content>
        <span class="text-large font-600 mr-3"> 首页 </span>
      </template>
    </el-page-header>
    <el-card class="box-card">
      <el-row>
        <el-col :span="2">
          <el-avatar :size="50" :src="avatarUrl" />
        </el-col>
        <el-col :span="22">
          <h3>
            欢迎回来,{{ store.state.userInfo.username }},{{ welcomeText }}
          </h3>
        </el-col>
      </el-row>
    </el-card>
    <el-card class="box-card">
      <template #header>
        <div class="card-header">
          <span>公司产品</span>
        </div>
      </template>
      <el-carousel :interval="4000" type="card" height="200px">
        <el-carousel-item v-for="item in 6" :key="item">
          <h3 text="2xl" justify="center">{{ item }}</h3>
        </el-carousel-item>
      </el-carousel>
    </el-card>
  </div>
</template>

<script setup>
import { userInfo } from "@/api/index";
import { computed } from "vue";
import { useStore } from "vuex";
const store = useStore();
const getUserInfo = () => {
  userInfo().then((res) => {
    console.log(res.data);
    store.commit("changeUserInfo", res.data);
  });
};
getUserInfo();
const avatarUrl = computed(() =>
  store.state.userInfo.avatar
    ? store.state.userInfo.avatar
    : "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"
);
const welcomeText = computed(() =>
  new Date().getHours() < 12 ? "要开心每一天" : "喝杯咖啡提提神把"
);
</script>
<style lang="scss" scoped>
.box-card {
  margin-top: 50px;
}
.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  line-height: 200px;
  margin: 0;
  text-align: center;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>
